﻿using PetaPoco;
using PmSoft;
using PmSoft.Caching;
using PmSoft.Entity;
using System.ComponentModel;

namespace Modules.Constructor
{
    /// <summary>
    /// 建设单位信息
    ///</summary>
    [TableName("constructor")]
    [Description("建设单位信息表")]
    [PrimaryKey("constructor_id", AutoIncrement = true)]
    [CacheSetting(true)]
    [Serializable]
    public class ConstructorInfo : IEntity, IProjectUser
    {
        /// <summary>
        /// 建设单位ID
        ///</summary>
        [Column("constructor_id")]
        public int ConstructorId { get; set; }

        /// <summary>
        /// 建设单位类型:个人、事业单位、政府机关、企业
        ///</summary>
        [Column("type")]
        public ConstructorType Type { get; set; }

        /// <summary>
        /// 建设单位名称、个人姓名
        ///</summary>
        [Column("name")]
        public string Name { get; set; }

        /// <summary>
        /// 建设信用代码、身份证号码
        ///</summary>
        [Column("code")]
        public string Code { get; set; }

        /// <summary>
        /// 安全信息ID
        ///</summary>
        [Column("security_id")]
        public int SecurityId { get; set; }

        /// <summary>
        /// 归属省代码
        ///</summary>
        [Column("province_code")]
        public int ProvinceCode { get; set; }

        /// <summary>
        /// 归属地市代码
        ///</summary>
        [Column("city_code")]
        public int CityCode { get; set; }

        /// <summary>
        /// 归属区县代码
        ///</summary>
        [Column("area_code")]
        public int AreaCode { get; set; }

        /// <summary>
        /// 注册地址
        ///</summary>
        [Column("reg_addr")]
        public string RegAddr { get; set; }

        /// <summary>
        /// 办公地址
        ///</summary>
        [Column("office_addr")]
        public string OfficeAddr { get; set; }

        /// <summary>
        /// 法人姓名
        ///</summary>
        [Column("legalman")]
        public string Legalman { get; set; }

        /// <summary>
        /// 法人身份证号码
        ///</summary>
        [Column("legal_cardno")]
        public string LegalCardno { get; set; }

        /// <summary>
        /// 法人手机号码
        ///</summary>
        [Column("legal_mobile")]
        public string LegalMobile { get; set; }

        /// <summary>
        /// 联系人
        ///</summary>
        [Column("link_man")]
        public string LinkMan { get; set; }

        /// <summary>
        /// 联系人电话
        ///</summary>
        [Column("link_tel")]
        public string LinkTel { get; set; }

        /// <summary>
        /// 创建时间
        /// 默认值: CURRENT_TIMESTAMP
        ///</summary>
        [Column("create_time")]
        public DateTime CreateTime { get; set; } = DateTime.Now;

        /// <summary>
        /// 默认项目ID
        /// </summary>
        [Column("project_id")]
        public int ProjectId { get; set; }

        /// <summary>
        /// 是否已认证
        /// </summary>
        [Column("has_auth")]
        public bool HasAuth { get; set; }

        #region IEntity 成员

        [Ignore]
        object IEntity.EntityId { get { return this.ConstructorId; } }

        #endregion IEntity 成员

        #region IUser

        [Ignore]
        string IUser.Name => this.Name;

        [Ignore]
        int IUser.Id => this.ConstructorId;

        [Ignore]
        UserType IUser.Type => UserType.Constructor;

        [Ignore]
        int? IProjectUser.ProjectId => this.ProjectId;

        #endregion IUser
    }
}